package com.mangatta.cloud.alarm;

import com.mangatta.cloud.Metric;
import com.mangatta.cloud.Statistic;

/**
 * Alarm configuration Details.
 */
public class AlarmConfiguration {
    private String instance;
    private Metric metric;
    private final Statistic statistic;
    private Double threshold;

    public AlarmConfiguration(String instance, Metric metric,
                              Statistic statistic, Double threshold) {
        this.instance = instance;
        this.metric = metric;
        this.statistic = statistic;
        this.threshold = threshold;
    }


    public void setInstance(String instance) {
        this.instance = instance;
    }


    public void setMetric(Metric metric) {
        this.metric = metric;
    }


    public void setThreshold(Double threshold) {
        this.threshold = threshold;
    }


    public Metric getMetric() {
        return metric;
    }

    public String getUnit() {
        return metric.getUnit();
    }

    public Statistic getStatistic() {
        return statistic;
    }


    public Double getThreshold() {
        return threshold;
    }


    public String getInstance() {
        return instance;
    }

    public String getDisplayName() {
        if (metric == null) {
            return "(No name)";
        }
        return metric.getDisplayName();
    }

    @Override
    public String toString() {
        return "AlarmConfiguration [instance=" + instance + ", metric="
                + metric + ", statistic=" + statistic + ", threshold="
                + threshold + "]";
    }

}
